package com.fz.service.system.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fz.common.ResponseEntity;
import com.fz.dto.system.job.JobAdd;
import com.fz.dto.system.job.JobQuery;
import com.fz.dto.system.job.JobUpd;
import com.fz.entity.system.Job;
import com.fz.mapper.system.JobMapper;
import com.fz.service.system.JobService;
import com.fz.vo.system.job.JobVo;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;

@Service
@SuppressWarnings("unchecked")
public class JobServiceImpl implements JobService {

    @Resource
    private JobMapper jobMapper;

    /**
     * @方法描述:  查找岗位
     * @参数:
     * @返回值:
     * @创建人: shy
     * @创建时间:: 2021/3/17
     */
    @Override
    public ResponseEntity<IPage<JobVo>> findJobList(JobQuery jobQuery, int pageNum, int pageSize) throws Exception {
        Page<JobVo> page = new Page<>(pageNum,pageSize);
        IPage<JobVo> JobQueryDataList = jobMapper.findJobList(page,jobQuery);
        return ResponseEntity.buildSuccess(JobQueryDataList);
    }

    /**
     * @方法描述:  增加岗位
     * @参数:
     * @返回值:
     * @创建人: shy
     * @创建时间:: 2021/3/17
     */
    @Override
    public ResponseEntity addJob(JobAdd jobAdd) throws Exception {
        Job job = new Job();
        job.setName(jobAdd.getName());
        job.setDeptId(jobAdd.getDeptId());
        job.setSort(jobAdd.getSort());
        job.setStatus(jobAdd.getStatus());
        jobMapper.insert(job);
        return ResponseEntity.buildSuccess();
    }

    /**
     * @方法描述:  更改岗位
     * @参数:
     * @返回值:
     * @创建人: shy
     * @创建时间:: 2021/3/17
     */
    @Override
    public ResponseEntity updateJob(JobUpd jobUpd) throws Exception {
        Job job = new Job();
        job.setId(jobUpd.getId());
        job.setName(jobUpd.getName());
        job.setDeptId(jobUpd.getDeptId());
        job.setSort(jobUpd.getSort());
        job.setStatus(jobUpd.getStatus());
        jobMapper.updateById(job);
        return ResponseEntity.buildSuccess();
    }


}
